package domain;

import java.util.Date;

public class Message implements Comparable<Message> {

	private int id;
	private Date createDate;
	private String msg;
	private Room room;
	private User user;
	
	public Message() {}
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public Date getCreateDate() {
		return createDate;
	}
	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
	public Room getRoom() {
		return room;
	}
	public void setRoom(Room room) {
		this.room = room;
	}
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}

	@Override
	public String toString() {
		return String.format("\nMessage ID [%1s], createdate [%2s], text [%3s], room [%4s]"
				, id, createDate, msg, room.toString() );//, (user == null ? "null" : user.getUserNickName()), user [%5s]
	}
	@Override
	public int compareTo(Message that) {
		//final int BEFORE = -1;
		//final int AFTER = 1;	
		//ascending orde		
		return this.createDate.compareTo(that.createDate);
	}
	
}
